import { List } from 'antd-mobile'
import axios from 'axios'
import React, { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'

function Home() {

    const [data, setData] = useState([])
    const navigate = useNavigate()

    const getData = async () => {
        const res = await axios.post('/api/trip/train', {
            "start": "北京",
            "end": "广州",
            "date": "string",
            "isSpeed": true,
            "isSeat": true,
            "isDesc": true,
            "page": 1
        })
        console.log(res);

        setData(res.data.data)
    }

    useEffect(() => {
        getData()
    }, [])

    return (
        <div>
            <div>
                {
                    data.map((item, index) => {
                        return <div onClick={() => {
                            navigate('/detail?id=' + item.id)
                        }} key={index} style={{ display: 'flex' }}>
                            <div>
                                <p>{item.start}</p>
                            </div>

                            <div style={{ marginLeft: ' 20px' }}>
                                <p>{item.end}</p>
                            </div>
                        </div>

                    })
                }

            </div>
        </div>
    )
}

export default Home